import http from 'Utils/ajax.js'
import * as type from './type.js'


export default {
    async getHome ({commit}, value) {
        let result = await http({
            url: 'https://fe-wcgi.jianke.com/v1/homepage',
            method: 'get',
            params: {
                type: 'home',
                platform: 'mobile'
            }
        })

        let action = {
            type: type.MODIFY_HOME,
            payload: result.data
        }

        commit(action)
    },
    
    async getCoupon ({commit}, value) {
        let result = await http({
            url: '/jianke/coupon/coupons/activities',
            method: 'get',
            params: {
                page: 1,
                size: 10
            }
            // url: 'http://localhost:8080/public/coupon.json'
        })
        console.log(result)
        let action = {
            type: type.MODIFY_COUPON,
            payload: result.data
        }
        commit(action)
    },

    async getMobile5 ({commit}, value) {
        let result = await http({
            url: 'https://fe-wcgi.jianke.com/v1/simple/products',
            method: 'get',
            params: {
                ids: value,
                platform: 'mobile'
            }
        })

        let action = {
            type: type.MODIFY_MOBILE5,
            payload: result.data
        }
        commit(action)
    },

    async getInstrument ({commit}, value) {
        let result = await http({
            url: 'https://acgi.jianke.com/promos/promos-batch/app/810635-1,11458-1,156198-1,8540-1,253640-1,829069-1,750600-1,563889-1,344132-1,226916-1,156296-1,491934-1',
            method: 'get',
            params: {
                _: 1559046111436
            }
        })

        let action = {
            type: type.MODIFY_INSTRUMENT,
            payload: result.data
        }
        commit(action)
    },
    
}